package enumandlambda;

import java.util.Random;

/**
 * @author shkstart
 * 在主线程中创建两个子线程，每个子线程中产生一个随机数，等待子线程结束后
 * 在主线程累加两个子线程的结果
 * @create 2022-12-01-20:48
 */
public class ThreadDemo14 {
    static int num1 = 0 ;
    static int num2 = 0 ;
    public static void main(String[] args) throws InterruptedException {

        Thread t1 = new Thread(()->{
           num1 = new Random().nextInt(10) ;
        });
        t1.start();

        Thread t2 = new Thread(()->{
            num2 = new Random().nextInt(10) ;
        });
        t2.start();

        t1.join();
        t1.join();
        System.out.println(num1+num2);
    }
}
